--- @param extension Package
--- @param HY HY_Utility
--- @param U Utility
return function(extension, HY, U)
    local hy_inaba_tewi = General:new(extension, "hy_inaba_tewi", "jin_k", 3, 3, General.Female)
    local make_trap = fk.CreateSkill {
        name = "make_trap",
    }
    make_trap:addEffect(fk.EventPhaseStart, {
        anim_type = "negative",
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(make_trap.name) and player.phase == Player.Discard and #player:getPile("$make_trap_trap") == 0
        end,
        on_cost = function(self, event, target, player, data)
            local room = player.room
            local cards = room:askToCards(player, {
                min_num = 1,
                max_num = 2,
                skill_name = make_trap.name,
                pattern = ".|.|.|hand",
                prompt = "make_trap_prompt1",
            })
            if type(cards) == "number" then
                cards = { cards }
            end
            event:setCostData(self, cards)
            return #cards > 0
        end,
        on_use = function(self, event, target, player, data)
            player:addToPile("$make_trap_trap", event:getCostData(self), false, make_trap.name)
        end
    })
    make_trap:addEffect(fk.CardUsing, {
        anim_type = "negative",
        can_trigger = function(self, event, target, player, data)
            return data.card:getEffectiveId() and player:hasSkill(make_trap.name) and target ~= player and #player:getPile("$make_trap_trap") > 0 and
                table.any(player:getPile("$make_trap_trap"), function(id)
                    return Fk:getCardById(id).type == data.card.type
                end)
        end,
        on_cost = function(self, event, target, player, data)
            local room = player.room
            event:setCostData(self, room:askToCards(player, {
                min_num = 1,
                max_num = 1,
                skill_name = make_trap.name,
                pattern = ".|.|.|$make_trap_trap|.|" .. data.card:getTypeString(),
                prompt = "make_trap_prompt2:::" .. data.card:getTypeString() .. ":" .. data.card:toLogString(),
                expand_pile = "$make_trap_trap"
            }))
            return #event:getCostData(self) > 0
        end,
        on_use = function(self, event, target, player, data)
            local room = player.room
            local card = Fk:getCardById(event:getCostData(self)[1])
            room:moveCardTo(card, Card.DiscardPile, nil, fk.ReasonPutIntoDiscardPile, make_trap.name, "$make_trap_trap", true)
            room:drawCards(player, 1, make_trap.name)
            data.nullifiedTargets = data.nullifiedTargets or {}
            table.insertTableIfNeed(data.nullifiedTargets, room:getAllPlayers())
            data:removeAllTargets()
        end
    })
    local cunning_wisdom = fk.CreateSkill {
        name = "cunning_wisdom",
    }
    cunning_wisdom:addEffect("active", {
        anim_type = "control",
        card_num = 1,
        target_num = 1,
        times = function(self, player)
            return player:getMark("cunning_wisdom-phase") == 0 and (3 - player:usedSkillTimes(cunning_wisdom.name, Player.HistoryPhase)) or 0
        end,
        can_use = function(self, player)
            return player:hasSkill(cunning_wisdom.name) and player.phase == Player.Play and player:usedSkillTimes(cunning_wisdom.name, Player.HistoryPhase) < 3 and
            player:getMark("cunning_wisdom-phase") == 0
        end,
        card_filter = function(self, player, to_select, selected)
            return #selected < 1 and table.contains(player:getCardIds("h"), to_select)
        end,
        target_filter = function(self, player, to_select, selected, selected_cards)
            return #selected < 1 and to_select ~= player and #to_select:getCardIds("h") > 0
        end,
        prompt = function(self, player, selected_cards, selected_targets)
            return "cunning_wisdom_prompt"
        end,
        on_use = function(self, room, cardUseEvent)
            local player = cardUseEvent.from
            local target = cardUseEvent.tos[1]
            local card = Fk:getCardById(cardUseEvent.cards[1])
            room:throwCard(card, cunning_wisdom.name, player, player)
            local show = Fk:getCardById(room:askToChooseCard(player, {
                target = target,
                flag = "h",
                skill_name = cunning_wisdom.name
            }))
            target:showCards(show)
            if show.type ~= card.type then
                room:moveCards({
                    from = target,
                    to = player,
                    ids = { show.id },
                    toArea = Card.PlayerHand,
                    moveReason = fk.ReasonPrey,
                    moveVisible = true,
                    skillName = cunning_wisdom.name,
                    proposer = player,
                })
                room:setPlayerMark(player, "cunning_wisdom-phase", 1)
            elseif not player.dead then
                room:drawCards(player, 1, cunning_wisdom.name)
            end
        end,
    })
    extension:loadSkillSkels { make_trap, cunning_wisdom }
    hy_inaba_tewi:addSkill("make_trap")
    hy_inaba_tewi:addSkill("cunning_wisdom")
    Fk:loadTranslationTable {
        ["hy_inaba_tewi"] = "因幡帝",
        ["#hy_inaba_tewi"] = "远古的狡黠",
        ["illustrator:hy_inaba_tewi"] = "YOU",
        ["designer:hy_inaba_tewi"] = "黑曜人形",
        ["cv:hy_inaba_tewi"] = "",

        ["make_trap"] = "设陷",
        [":make_trap"] = "弃牌阶段开始时，若你没有“陷”，你可以将至多两张手牌作为“陷”扣置于武将牌上。其他角色使用非虚拟牌时，你可以移去一张相同类型的“陷”，然后令此牌无效并摸一张牌。",
        ["make_trap_prompt1"] = "设陷：你可以将至多两张手牌作为“陷”扣置于武将牌上",
        ["make_trap_prompt2"] = "设陷：你可以弃置一张%arg的“陷”令%arg2无效",
        ["$make_trap_trap"] = "陷",

        ["cunning_wisdom"] = "黠智",
        [":cunning_wisdom"] = "出牌阶段限三次，你可以弃置一张手牌并展示一名其他角色的一张手牌：若与此牌类型不同，你获得之且本阶段“黠智”失效；否则你摸一张牌。",
        ["cunning_wisdom_prompt"] = "黠智：你可以弃置一张手牌并展示一名其他角色的一张手牌",
    }
end
